﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Xml;

using System.Diagnostics;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Process batch = new Process();
        Process batch2 = new Process();
        public Form1()
        {
            InitializeComponent();
           
          
            
            

        }

        String nodepatch = "";
        String mongopatch = "";

        private void Form1_Load(object sender, EventArgs e)
        {
            



            XmlTextReader reader = new XmlTextReader("settings.xml");
            while (reader.Read())
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "node") 
                    {
                        nodepatch = reader.ReadString();
                        this.textBox1.Text = nodepatch;
                    }

                    if (reader.Name == "mongo")
                    {
                        mongopatch = reader.ReadString();
                        this.textBox2.Text = mongopatch;
                    }
                }


        
        }


        private void button2_Click(object sender, EventArgs e)
        {
            batch.StartInfo.FileName = "cmd.exe";
            batch.StartInfo.WorkingDirectory = @"" + nodepatch;
            batch.StartInfo.Arguments = "/c node server";
            batch.Start();
           // batch.WaitForExit();
          //  batch.Close();
        

           
        }

        private void button3_Click(object sender, EventArgs e)
        {

            batch2.StartInfo.FileName = "cmd.exe";
            batch2.StartInfo.WorkingDirectory = @"" + mongopatch;
            batch2.StartInfo.Arguments = "/c mongod";
            batch2.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            batch.Close();
            batch2.Close();
        }
    }
}
